home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / perl / perl30 / drives.bat < prev    next >
DOS Batch File  |  1990-05-09  |  1KB  |  47 lines

  1. @REM=("
  2. @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  3. @goto end ") if 0 ;
  4.  
  5. #
  6. # Test the ioctl function for MS-DOS.  Provide a list of drives and their
  7. # characteristics.
  8. #
  9. # By Diomidis Spinellis.
  10. #
  11.  
  12. @fdnum = ("STDIN", "STDOUT", "STDERR");
  13. $maxdrives = 15;
  14. for ($i = 3; $i < $maxdrives; $i++) {
  15.     open("FD$i", "nul");
  16.     @fdnum[$i - 1] = "FD$i";
  17. }
  18. @mediatype = (
  19.     "320/360 k floppy drive",
  20.     "1.2M floppy",
  21.     "720K floppy",
  22.     "8'' single density floppy",
  23.     "8'' double density floppy",
  24.     "fixed disk",
  25.     "tape drive",
  26.     "1.44M floppy",
  27.     "other"
  28. );
  29. print "The system has the following drives:\n";
  30. for ($i = 1; $i < $maxdrives; $i++) {
  31.     if ($ret = ioctl(@fdnum[$i], 8, 0)) {
  32.         $type = ($ret == 0) ? "removable" : "fixed";
  33.         $ret = ioctl(@fdnum[$i], 9, 0);
  34.         $location = ($ret & 0x800) ? "local" : "remote";
  35.         ioctl(@fdnum[$i], 0x860d, $param);
  36.         @par = unpack("CCSSSC31S", $param);
  37.         $lock = (@par[2] & 2) ? 
  38.             "supporting door lock" : 
  39.             "not supporting door lock";
  40.         printf "%c:$type $location @mediatype[@par[1]] ", ord('A')+$i-1;
  41.         printf "@par[3] cylinders @par[6] sectors/track $lock\n";
  42.     }
  43. }
  44.  
  45. @REM=("
  46. :end ") if 0 ;
  47.